Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for canonical links #1001

Merged
merged 3 commits into from
Oct 18, 2024
Merged

Conversation

davidgs
Copy link
Contributor

@davidgs davidgs commented Oct 15, 2024

Issue

Fixes #1000

Description

Add support for canonical links in frontmatter. If you post to an external site, and also want to post to your own site, you must use a <link rel="canonical" in the header or search engines will refuse to index it (on either site!)

Test Evidence

canonical1

canonical2

Add a `relcanonical: <URL>` item to the frontmatter and this will then make sure that the `<link rel="canonical" >` value is set properly.
Copy link

netlify bot commented Oct 15, 2024

Deploy Preview for toha-ci ready!

Name Link
🔨 Latest commit f728c19
🔍 Latest deploy log https://app.netlify.com/sites/toha-ci/deploys/6712aca96c02b20008e3bb80
😎 Deploy Preview https://deploy-preview-1001--toha-ci.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hossainemruz
Copy link
Member

HI @davidgs! Thank you for the PR. If I understand it correctly, this only necessary for post pages right? In that case, I will recommend to add it here:

<meta name="description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Title }}{{ end }}" />

There is no need to separate this single line into a partial template.

@davidgs
Copy link
Contributor Author

davidgs commented Oct 18, 2024

As long as that works, I'm happy! Just having real canonical working is a win!

@davidgs
Copy link
Contributor Author

davidgs commented Oct 18, 2024

Works just fine. Moved to single.html and removed canonical.html and the code in based.html

Copy link
Member

@hossainemruz hossainemruz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @davidgs

@hossainemruz hossainemruz merged commit 2f670db into hugo-toha:main Oct 18, 2024
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: support for canonical links
2 participants